//#include "topsidebar.h"
//#include <QStyleOption>
//#include <QPainter>
//#include <QLineEdit>
//#include <QLabel>

//TopSidebar::TopSidebar(QWidget *parent) : QWidget(parent){
//    // 搜索框控件
//    QLineEdit *lineEdit = new QLineEdit(this);
//    lineEdit->move(90, 150);
//    lineEdit->resize(220, 35);
//    lineEdit->setStyleSheet("border: 1px solid lightgray; border-radius: 10px;");
//    lineEdit->setPlaceholderText("请输入搜索内容");
//    lineEdit->setClearButtonEnabled(true); //显示清除按钮
//    lineEdit->addAction(QIcon("://res/UI/search.png"), QLineEdit::LeadingPosition); //显示搜索图标

//    // logo显示
//    // logo显示
//    QLabel *logo = new QLabel(this);
//    logo->setStyleSheet("border: none; color: black; font-size: 12px; image: url(:/image.png); image-position: top center;");
//    // 使用HTML语法来定义图片和文字
//    logo->setText("<img src=':/img/res/img/logo1.png' width='40' height='40'><div style=>简评一下</div>"); //'text-align: center;'
//    logo->move(30, 130);
//    logo->resize(60, 80);

//}

//void TopSidebar::paintEvent(QPaintEvent *event)
//{
//    // 启用样式表
//    QStyleOption opt;
//    opt.initFrom(this);
//    QPainter p(this);
//    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);

//    // 以样式表方式重绘自身
//    QString styleSheet = "background-color: transparent;"
//                         "border: 1px solid rgb(229, 142, 72);"
//                         "border-radius: 25px;";
//    setStyleSheet(styleSheet);
//    //BSbar->set();
//    resize(400, 200);
//    move(-5, -130);

//}


#include "topsidebar.h"
#include <QStyleOption>
#include <QPainter>
#include <QLineEdit>
#include <QLabel>

TopSidebar::TopSidebar(QWidget *parent) : QWidget(parent) {
    setStyleSheet("background-color: transparent; border: 1px solid rgb(229, 142, 72); border-radius: 25px;");
    resize(400, 200);
    move(-5, -130);

    CreateSearchBox();
    CreateLogo();
}

void TopSidebar::paintEvent(QPaintEvent *event) {
    Q_UNUSED(event);

    QStyleOption opt;
    opt.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}

void TopSidebar::CreateSearchBox() {
    QLineEdit *lineEdit = new QLineEdit(this);
    lineEdit->setGeometry(90, 150, 220, 35);
    lineEdit->setStyleSheet("border: 1px solid lightgray; border-radius: 10px;");
    lineEdit->setPlaceholderText("请输入搜索内容");
    lineEdit->setClearButtonEnabled(true); // 显示清除按钮
    lineEdit->addAction(QIcon(":/res/UI/search.png"), QLineEdit::LeadingPosition); // 显示搜索图标
}

void TopSidebar::CreateLogo() {
    QLabel *logo = new QLabel(this);
    logo->setStyleSheet("border: none; color: black; font-size: 12px; image: url(:/image.png); image-position: top center;");
    // 使用HTML语法来定义图片和文字
    logo->setText("<img src=':/img/res/img/logo1.png' width='40' height='40'><div style=>简评一下</div>"); //'text-align: center;'
    logo->move(30, 125);
    logo->resize(60, 80);
}
